package com.zhanglingfei.yuekaobasics.kafka;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.annotation.TopicPartition;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class KafkaConsumer {

    /**
     * kafka消费者
     * @param record
     * @param ack
     */
    @KafkaListener(topicPartitions = @TopicPartition(topic = "kafkaTest-p1",partitions = {"0"}))
    public void consumer(ConsumerRecord<String,String> record, Acknowledgment ack) {
        log.info("接收消息0：{}",record.value());
    }

}
